package com.liy.framework.common.office.pdf;

import java.io.IOException;
import org.apache.pdfbox.multipdf.PDFMergerUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PdfUtil {
    protected static Logger log = LoggerFactory.getLogger(PdfUtil.class);

    public PdfUtil() {
    }

    public static void mergePDF(String destFilePath, String[] fileListPath) throws IOException {
        log.info("开始合并PDF文件：" + destFilePath);
        long start = System.currentTimeMillis();
        PDFMergerUtility mergePdf = new PDFMergerUtility();
        String[] var5 = fileListPath;
        int var6 = fileListPath.length;

        for(int var7 = 0; var7 < var6; ++var7) {
            String path = var5[var7];
            mergePdf.addSource(path);
        }

        mergePdf.setDestinationFileName(destFilePath);
        mergePdf.mergeDocuments();
        long end = System.currentTimeMillis();
        log.info("开始合并PDF文件完成，用时：" + (end - start) + "ms");
    }

    public static void main(String[] args) {
        String[] fileListPath = new String[]{"H:\\D达实智能\\报销\\发票\\2019-04\\8f7af886325c7a69a4b0ea1e2f521ce1.pdf", "H:\\D达实智能\\报销\\发票\\2019-04\\044001800311-74183844.pdf", "H:\\D达实智能\\报销\\发票\\2019-04\\04403170011119080234.pdf", "H:\\D达实智能\\报销\\发票\\2019-04\\04403180021112515031.pdf", "H:\\D达实智能\\报销\\发票\\2019-04\\04403190011123483041.pdf", "H:\\D达实智能\\报销\\发票\\2019-04\\04403190011123483712.pdf", "H:\\D达实智能\\报销\\发票\\2019-04\\c8ad6b3bbb8bd9e478c386f9993dba1f.pdf", "H:\\D达实智能\\报销\\发票\\2019-04\\1.pdf", "H:\\D达实智能\\报销\\发票\\2019-04\\2.pdf"};

        try {
            mergePDF("H:\\D达实智能\\报销\\发票\\2019-04\\发票.pdf", fileListPath);
        } catch (IOException var3) {
            var3.printStackTrace();
        }

    }
}
